<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>考试管理系统</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }

        body {
            background-color: #f4f6f9;
            display: flex;
            min-height: 100vh;
        }

        .container {
            width: 100%;
            display: flex;
        }

        /* 侧边栏样式 */
        .sidebar {
            width: 250px;
            background-color: #2f4050;
            color: white;
            padding: 20px;
            height: calc(100vh - 60px);
            position: fixed;
            left: 0;
            top: 60px;
            transition: width 0.3s ease;
        }

        .sidebar.collapsed {
            width: 80px;
        }

        .sidebar.collapsed .logo img {
            max-width: 50px;
        }

        .sidebar.collapsed .nav-links li a span {
            display: none;
        }

        .sidebar.collapsed .nav-links li.sub-menu ul {
            left: 100%;
            top: 0;
        }

        .logo {
            text-align: center;
            margin-bottom: 30px;
        }

        .logo img {
            max-width: 150px;
            height: auto;
            transition: max-width 0.3s ease;
        }

        .nav-links {
            list-style: none;
            padding: 0;
        }

        .nav-links li {
            margin-bottom: 10px;
            position: relative;
        }

        .nav-links li a {
            display: block;
            padding: 12px 20px;
            color: white;
            text-decoration: none;
            border-left: 3px solid transparent;
            border-radius: 5px;
            transition: all 0.3s ease;
            position: relative;
        }

        .nav-links li a i {
            margin-right: 10px;
        }

        .nav-links li a:hover {
            background-color: rgba(255, 255, 255, 0.1);
            border-left: 3px solid #1ab394;
        }

        .nav-links li a.active {
            background-color: #1ab394;
            color: white;
            border-left: 3px solid #179d82;
        }

        /* 仅为有子菜单的父菜单项添加箭头 */
        .nav-links li.sub-menu > a:after {
            content: "\f078";
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            position: absolute;
            right: 20px;
            font-size: 12px;
            opacity: 0.5;
            transition: transform 0.3s ease;
        }

        .nav-links li.sub-menu.active > a:after {
            transform: rotate(-180deg);
        }

        .nav-links li.sub-menu ul {
            display: none;
            list-style: none;
            padding-left: 20px;
            margin-top: 10px;
            background-color: rgba(0, 0, 0, 0.1);
            border-radius: 5px;
        }

        .nav-links li.sub-menu.active ul {
            display: block;
        }

        /* 主内容区域样式 */
        .main-content {
            margin-left: 250px;
            padding: 20px;
            width: calc(100% - 250px);
            height: calc(100vh - 60px);
            overflow-y: auto;
            position: relative;
            top: 60px;
            transition: margin-left 0.3s ease;
        }

        .main-content.expanded {
            margin-left: 80px;
            width: calc(100% - 80px);
        }

        /* 顶部导航样式 */
        .top-nav {
            position: fixed;
            top: 0;
            left: 0;
            right: 0;
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: white;
            padding: 15px 20px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            z-index: 1000;
            height: 60px;
        }

        .top-nav .logo {
            display: flex;
            align-items: center;
            margin-right: 0;
            padding-top: 5px;
        }

        .top-nav .logo img {
            height: 50px;
            width: auto;
            object-fit: contain;
            margin-top: 25px;
        }

        .top-nav ul {
            display: flex;
            list-style: none;
            margin: 0;
            padding: 0;
        }

        .top-nav ul li {
            margin-right: 15px;
            position: relative;
        }

        .top-nav ul li a {
            text-decoration: none;
            color: #333;
            padding: 5px 10px;
            border: 1px solid transparent;
            border-radius: 4px;
            transition: all 0.3s ease;
            position: relative;
        }

        .top-nav ul li a.active {
            background-color: #1ab394;
            color: white;
            border-color: #1ab394;
        }

        /* 移除顶部导航栏链接后面的箭头 */
        .top-nav ul li a:after {
            display: none;
        }

        /* 用户信息和菜单样式 */
        .user-info {
            font-size: 14px;
            color: #333;
            margin-left: auto;
            display: flex;
            align-items: center;
            position: relative;
        }

        .user-info i {
            margin-right: 5px;
        }

        .user-info span {
            font-weight: bold;
        }

        .user-menu {
            display: none;
            position: absolute;
            top: 100%;
            right: 0;
            background-color: white;
            border: 1px solid #e0e0e0;
            border-radius: 8px;
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
            padding: 10px;
            z-index: 1001;
            flex-direction: column;
            align-items: flex-start;
        }

        .user-menu a {
            display: block;
            color: #666;
            text-decoration: none;
            margin: 8px 0;
            padding: 8px 15px;
            border-radius: 6px;
            transition: background-color 0.3s ease, color 0.3s ease;
            font-size: 14px;
        }

        .user-menu a:hover {
            background-color: #f4f4f4;
            color: #333;
        }

        .user-info:hover .user-menu {
            display: flex;
        }

        /* 数据统计区域样式 */
        .stats {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }

        .stat-item {
            padding: 20px;
            text-align: center;
            border-radius: 8px;
            color: white;
            font-size: 16px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            transition: transform 0.3s ease;
        }

        .stat-item:hover {
            transform: translateY(-5px);
        }

        .blue {
            background-color: #1ab394;
        }

        .green {
            background-color: #28a745;
        }

        .red {
            background-color: #dc3545;
        }

        /* 图表区域样式 */
        .chart-section {
            background-color: white;
            padding: 20px;
            border-radius: 8px;
            margin-bottom: 20px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }

        .system-notice h3 {
            margin-bottom: 10px;
            color: #333;
        }

        .system-notice p {
            color: #666;
            line-height: 1.6;
        }

        /* 响应式样式 */
        @media (max-width: 768px) {
            .sidebar {
                width: 100%;
                height: auto;
                position: relative;
                top: 0;
            }

            .main-content {
                margin-left: 0;
                padding: 15px;
                padding-top: 60px;
                height: calc(100vh - 60px);
                overflow-y: auto;
            }

            .stats {
                grid-template-columns: 1fr;
            }
        }
    </style>
</head>

<body>
<div class="container">
    <!-- 左侧导航栏 -->
    <div class="sidebar" id="sidebar">
        <ul class="nav-links">
            <li><a href="#" class="active"><i class="fas fa-home"></i><span>首页</span></a></li>
            <li class="sub-menu">
                <a href="#"><i class="fas fa-cog"></i><span>系统管理</span></a>
                <ul>
                    <li><a href="#">用户管理</a></li>
                </ul>
            </li>
            <li class="sub-menu">
                <a href="#"><i class="fas fa-clock"></i><span>考试详情</span></a>
                <ul>
                    <li><a href="#">成绩汇总</a></li>
                    <li><a href="#">成绩明细</a></li>
                </ul>
            </li>
            <li class="sub-menu">
                <a href="#"><i class="fas fa-tasks"></i><span>题库管理</span></a>
                <ul>
                    <li><a href="#">题库添加</a></li>
                </ul>
            </li>
        </ul>
    </div>
    <!-- 主内容区域 -->
    <div class="main-content" id="main-content">
        <!-- 顶部导航 -->
        <div class="top-nav">
            <div class="logo">
                <img src="logo.png" alt="考试管理系统">
            </div>
            <div class="user-info">
                <i class="fas fa-user"></i>
                <span>余维翰</span>
                <div class="user-menu">
                    <a href="#">个人信息</a>
                    <a href="#">退出登录</a>
                </div>
            </div>
        </div>
        <!-- 数据统计区域 -->
        <div class="stats">
            <div class="stat-item blue">
                <span id="totalExaminees">0</span>
                <p>考试总人数</p>
            </div>
            <div class="stat-item green">
                <span id="attendedExaminees">0</span>
                <p>已参加人数</p>
            </div>
            <div class="stat-item red">
                <span id="unattendedExaminees">0</span>
                <p>未参加人数</p>
            </div>
        </div>
        <!-- 工时填报图表区域 -->
        <div class="chart-section">
            <canvas id="timesheetChart"></canvas>
        </div>
    </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
    // 初始化图表
    document.addEventListener('DOMContentLoaded', function () {
        const ctx = document.getElementById('timesheetChart').getContext('2d');
        const timesheetChart = new Chart(ctx, {
            type: 'line',
            data: {
                labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
                datasets: [{
                    label: '工时填报',
                    data: [8, 6, 7, 5, 8, 4, 3],
                    borderColor: '#1ab394',
                    backgroundColor: 'rgba(26, 179, 148, 0.2)',
                    borderWidth: 1
                }]
            },
            options: {
                responsive: true,
                scales: {
                    y: {
                        beginAtZero: true
                    }
                }
            }
        });

        // 模拟从 Java 接口获取数据
        function fetchExamData() {
            // 这里可以替换为实际的 Java 接口地址
            const apiUrl = 'your-java-api-url';
            fetch(apiUrl)
                .then(response => response.json())
                .then(data => {
                    const totalExaminees = document.getElementById('totalExaminees');
                    const attendedExaminees = document.getElementById('attendedExaminees');
                    const unattendedExaminees = document.getElementById('unattendedExaminees');

                    totalExaminees.textContent = data.totalExaminees;
                    attendedExaminees.textContent = data.attendedExaminees;
                    unattendedExaminees.textContent = data.unattendedExaminees;
                })
                .catch(error => {
                    console.error('获取数据失败:', error);
                });
        }

        // 调用函数获取数据
        fetchExamData();

        // 点击侧边栏菜单展开子菜单
        const subMenuItems = document.querySelectorAll('.nav-links li.sub-menu');
        subMenuItems.forEach(item => {
            const link = item.querySelector('a');
            link.addEventListener('click', function (e) {
                e.preventDefault();
                item.classList.toggle('active');
            });
        });
    });
</script>
</body>

</html>